This invention relates to computer programs for the development of other programs and, more particularly, to computer programs which provide Integrated Development Environments.
An Integrated Development Environment (IDE) is an application or set of program modules run from a single user interface which provides an environment for the development of application programs in particular computer languages. IDEs typically provide development assistance for the language or languages the IDE supports. These languages include both programming languages such as Pascal and Java, and markup languages like HTML or XML. Development assistance includes features such as syntax highlighting, structure analysis, error reporting, completion assistance and context-sensitive help. An example of an IDE is the JBuilder product made by Borland Software Corporation of Scotts Valley, Calif.
Syntax highlighting is a feature by which different elements of the language grammar, such as reserved words, symbols, literal values, and comments, are displayed with different colors and/or attributes to make them more easily distinguished. Structure analysis and error reporting features provide information as the program is developed, such as a separate tree/outline of the file contents, and visual indications of whether the syntax of the file is valid. For example, an outline for a Java source file could show an alphabetized list of all the program object methods and fields in an object class that can be used to immediately navigate to that element in the file. This feature can also show syntax errors, such as missing statement terminators (e.g., semicolons), mismatched parentheses or braces, and invalid keyword combinations. Such information is tied to a particular position in the file whenever possible, so that the user can immediately locate that element of code or error.
Another typical IDE feature is completion assistance. When this feature is present, the IDE suggests valid names for program classes, elements, methods, variables, attributes and the like for the current position in the source code, usually in a popup list. It may also describe the available choices to some degree, obviating the need to consult other documentation or references. Optionally the completion assistance may automatically insert text into the source file, such as the second of a set of paired symbols when the first is typed by the user, or the rest of a name when there is only one valid name that starts with what the user has already typed.
IDEs also often provide context-sensitive help. In particular, when help is requested, the help that is provided relates to the code at that location of the cursor, e.g., present the definition of a command or required parameters. This help also displays available documentation for the current element in the source file, e.g., keyword, symbol, class, method, or field, etc.
The idea of having more than one language in a single source file is not new (such as embedding SQL in C files). In fact, the practice has become widespread with the desire to provide dynamic content for the Internet. To this end, many programming languages are being combined with markup languages in a single file to form hybrid-language files. However, these new hybrid files are no longer valid instances of their constituent languages. For example, Java Server Pages (JSPs), which can be created by JBuilder, embeds Java code inside a template, which is usually a markup language, most commonly HTML. The HTML portion could also contain embedded code in JavaScript and/or VBScript, so a JSP could easily contain three or four different languages. Such files are not intended to be directly displayed as HTML, nor are they valid Java source files that can be compiled as-is.
In addition, these hybrid file formats often introduce some syntax or language of their own in order to delineate the other constituent languages, and/or to provide features. These features may be used to bridge those languages or to provide entirely new functionality for the hybrid file format. For example, JSPs specify syntax to differentiate between Java expressions, statements, and declarations; add imports; declare JavaBeans; and declare pages to handle errors.
Because an IDE knows (or can be told) the syntax and languages that comprise the hybrid file, the xe2x80x9cproblemxe2x80x9d is to provide the same forms of development assistance that are typical for those languages, both separately and in concert. Complete development assistance therefore requires not only solving the general problem of multiple languages in the same file, but any inter-language issues. For example, while the kind of completion assistance may remain specific to the language at the current position in file, the suggestion of valid names may be affected by other sections of the file that are in a different language. An instance of this example is the use of JSP-specific syntax to declare Java imports. In this case, a JSP-to-Java converter in the IDE handles the embedded code by recognizing the JSP syntax ( less than % @page import=xe2x80x9csome.package.or.classxe2x80x9d %  greater than ) and converts it to the Java equivalent (import some.package.or.class;).
IDEs known in the prior art do not provide comprehensive development assistance for mixed-language sources. In most hybrid file formats, one of the languages is dominant. Therefore, the IDE treats the hybrid as that dominant type, providing assistance for that language, with little or no help for the other language(s). For example, a JSP can be considered mostly HTML with Java embedded in it. An IDE would then provide the usual HTML assistance features, while treating the embedded Java as simple text, with no assistance for it.
Thus, it would be advantageous if there were a way to provide development assistance for all of the languages used in a hybrid or mixed language file developed in an IDE.
The present invention is directed to providing development assistance for multiple languages in an Integrated Development Environment (IDE). In particular, the present invention provides a system by which development assistance, such as syntax highlighting, structure analysis, error reporting, completion assistance and context-sensitive help, is provided appropriately for each language in hybrid files developed in the IDE. This makes the problem of developing such mixed language programs much easier, since all of the development assistance typically available in an IDE for a single language is made available for all or any of the languages used in the IDE.
In an illustrative embodiment of the invention, the existing components that provide development assistance features for each constituent language are used to provide assistance for these languages in a mixed language file. Selective components which provide the assistance in a single languages are enhanced so that they can inter-operate on a mixed-language source file. The nature of the enhancement varies with the type of assistance. In particular, the mixed-language file M may contain the languages L1 (e.g., HTML), L2 (e.g., Java), L3 (e.g., JavaScript), and so forth, in addition to any M-specific syntax; where L1 is the dominant language. For example, M may be a JSP file that uses these languages and is created in JBuilder. M type refers to the file format defined in the specification for M-syntax or general file type as indicated by the extension in a filename. The specification for M-syntax includes a framework for the multiple-language file.
Syntax assistance is typically provided for individual languages by scanner programs S that identify the syntax of the code as it is being written. The scanner looks for characteristic symbols and keywords, and their relative position in the text, to identify elements, determine the syntax, and highlight the code-element according to a predetermined style. To implement this in a mixed language file, the scanners S1, S2, S3 for each language are enabled. However, at least one of the scanners, e.g., S1 for the dominant language, is modified to recognize the additional mixed or M-specific syntax and, if necessary, identify the presence of other constituent language(s). The enhanced scanner is thus adapted for the primary language. However, the scanner need not understand these languages, since the other scanners are activated for that purpose.
Structure analysis and error reporting can be implemented using existing parser programs P for the constituent languages. The concept is to apply the appropriate parser for each section of code depending on the language of the code. The parser for the dominant language may be enhanced to recognize the M-syntax as well as the subject language. However, some sections of code in some languages do not constitute self-contained code in their language which is amenable to parsing, even though the code may be valid in context within the M file. Therefore, applying the corresponding parser for a language to the section of code as it appears in M would result in an inflated number of errors. Instead of parsing the section of code out of context, the section of code may be converted to self-contained code using the framework provided by the specifications for M and the corresponding parser may be applied to the converted code. In this way only genuine errors in the file are detected and the structure is more accurately determined by the parser. Thus, converters are provided for those constituent languages susceptible to misinterpretation by the parser. Upon application of the converter to a section of code, revised code is produced and stored in a buffer on which the corresponding parser may operate. For any constituent language which does not pose complications to the parser when removed from its context in M, an accumulator may be applied to collect the sections of code for that language in a single buffer or file. The conversion or accumulation processes may be performed prior to applying the parsers. The enhanced parser for the dominant language operates on the sections of code in the dominant language or the M language, but substantially ignores the code in other languages which are processed by the other parsers. However, the results of all the processors are organized and presented to the user/programmer according to the original mixed language file M.
Completion assistance is a further type of development assistance that can be incorporated into an existing IDE to provide enhanced mixed language functionality. In a standard IDE there is a framework for various completion engines E, and a common mechanism for invoking them. Either the engine causes automatic completion of the source code generation or it displays a user interface that contains suggestions for completion. Each of the languages L1, L2, L3 has a completion engine E1, E2, E3, respectively, that operates upon the buffer that represents the file for which completion help is requested, based on an indicated position in that buffer. Optionally, access is provided to the source code used as the basis for files generated by converters (e.g. Java base classes used in JSP implementation classes) that contain useful information like formal parameter names for methods to assist in the completion of the source code. When access to the source code is not available, generic parameter names may be used, e.g., p1, p2, etc. An aspect of the proponent invention is to tie in those JSP implementation class sources with the code generated by the converter to provide better information.
To implement completion assistance, the various completion engines are modified to recognize M as an additional potential file type for their language. If the engine is invoked for an instance of M, and a converter C or accumulator A is used for that constituent language, then the converter/accumulator is invoked so that code in that language is stored in a new buffer. That buffer""s contents are substituted for the original content of M. The position in the buffer passed to the engine must also be modified using the recorded position mappings. If a converter uses source code that is available, it automatically informs the engine of that source code, so that the engine may present information contained therein.
If an IDE uses the completion assistance and/or structure analysis functionality of the present invention to identify the element for which help is requested, the enhancements applied to those subsystems enable help for M, requiring only that M be added as a valid type for this feature. Thus, help can be language specific, even for a mixed language file.